/*
 * @Author: lsjweiyi 759209794@qq.com
 * @Date: 2024-02-01 22:23:50
 * @LastEditors: lsjweiyi 759209794@qq.com
 * @LastEditTime: 2024-02-02 22:47:30
 * @FilePath: \random-drawing-machine\get-companies.go
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package main

import (
	"os"
	"strings"
)

type Icompanies struct {
	Errormsg  string
	Companies []string
}

func GetCompanies() Icompanies {

	// 读取文件内容
	content, err := os.ReadFile("选项.txt")
	if err != nil {
		if os.IsNotExist(err) {
			return Icompanies{Errormsg: "未找到文件“选项.txt”，请在程序同级目录下添加“选项.txt”"}
		} else {
			return Icompanies{Errormsg: err.Error()}
		}
	}


	// 按行分割内容
	lines := strings.Split(string(content), "\r\n")
	return Icompanies{Companies: lines}
}
